#include "quesion13.h"
#include <string>
#include <cstring>
#include <map>

using namespace std;


int quesion13::romanToInt(string s)
{
    map<char,int> rtoi = {
        {'I',1},
        {'V',5},
        {'X',10},
        {'L',50},
        {'C',100},
        {'D',500},
        {'M',1000}
    };
    int re = 0;
    for(int i = 0;i<s.length();i++){
        if(rtoi[s[i]]<rtoi[s[i+1]]){
            re = re-rtoi[s[i]];
        }
        else{
            re = re+rtoi[s[i]];
        }
    }
    return re;
}
